﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.Services;

namespace WebServiceTest
{
    public class Helper
    {
        public static void WriteLog(Exception ex)
        {
            string path = System.AppDomain.CurrentDomain.BaseDirectory + "\\log";

            if (!Directory.Exists(path))
            {
                //创建日志文件夹 
                Directory.CreateDirectory(path);
            }

            FileStream fs1 = new FileStream(path + "\\" + DateTime.Now.ToString("yyyy-MM-dd") + ".txt", FileMode.Append);

            using (StreamWriter sw = new StreamWriter(fs1))
            {
                sw.Write("[" + DateTime.Now.ToString("yyy-MM-dd HH:mm:ss") + "]" + ex.Message + "\r\n");
                sw.Flush();
                sw.Close();
            }
        }
    }
}